home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
PROGRAMMING
/
LCLINT2.SPK
/
test
/
test_b
/
c
/
sharing2
< prev
next >
Wrap
Text File
|
1996-08-28
|
822b
|
49 lines
extern /*@out@*/ /*@only@*/ void *smalloc (unsigned int size);
typedef int mint;
typedef struct _st
{
int a;
/*@only@*/ int *b;
/*@shared@*/ mint *c;
int d;
} *st;
/*@only@*/ st st_create1 ()
{
st res = (st) smalloc (sizeof(struct _st));
int *z;
res->a = 3;
z = res->b; /* res->b not defined */
z = (*res).c; /* (*res).c not defined */
return res; /* res->d not defined */
}
void f1(/*@only@*/ st x)
{
free (x->b);
free (x);
} /* correct */
void f2(/*@only@*/ st x)
{
free (x);
} /* bad --- didn't release x->b */
void f3(/*@only@*/ st x)
{
free (x->c); /* bad --- x->c is shared */
} /* bad --- didn't release x */
/*@only@*/ st st_create ()
{
st res = (st) smalloc(sizeof(struct _st));
res->a = 3;
return res; /* 6, 7, 8. res->b, res->c, res->d not defined */
}